package com.cskaoyan.demo3.servlet;

import com.cskaoyan.demo3.bean.User;
import com.cskaoyan.demo3.bean.UserDetail;
import com.cskaoyan.demo3.mapper.UserDetailMapper;
import com.cskaoyan.demo3.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/userdetail")
public class work5_userdetail extends HttpServlet {
    static SqlSession sqlSession;
    static UserDetailMapper userDetailMapper;
    static {
        sqlSession = MybatisUtil.getSqlSession();
        userDetailMapper = sqlSession.getMapper(UserDetailMapper.class);
    }
    @Test
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<UserDetail> userDetailList = userDetailMapper.selectAllUserDetail();
        for (UserDetail userDetail : userDetailList) {
            resp.getWriter().println(userDetail);
        }
    }
}
